<!-- 绿色通道 - 患者列表 - 医疗记录 主界面 -->
<template>
  <div id="box">
    <div class="topLine" style="">
      <div class="blueDot" style="" />
      <div style="float: left; margin-top: 8px">
        <span style="text-align: left; font-size: 20px; margin-left: 8px">医疗记录</span>
        <span v-if="insname ? insname = '驻马店市中心医院' : false" style="margin-left: 30px;">姓名：{{ persondata.name }}</span>
        <span v-if="insname ? insname = '驻马店市中心医院' : false" style="margin-left: 10px;">年龄：{{ persondata.age }}</span>
        <span v-if="insname ? insname = '驻马店市中心医院' : false" style="margin-left: 10px;">性别：{{ persondata.sex }}</span>
      </div>
      <div class="fanhui_btn" style="float: right">
        <el-button type="info" plain @click="routerBack()">
          <span class="iconfont icon-fanhui" />
          返回
        </el-button>
      </div>
      <div style="clear: both" />
    </div>
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane label="急救进程" name="process"><process v-if="activeName == 'process'" :checkrowdata="mrdata" /></el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="远程会诊" name="remoteConsultation"><remoteConsultation v-if="activeName == 'remoteConsultation'" patient-type="胸痛" :checkrowdata="mrdata" /></el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="基本信息" name="info"><info v-if="activeName == 'info'" :checkrowdata="mrdata" /></el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="生命体征" name="vitalSign"><vitalSign v-if="activeName == 'vitalSign'" patient-type="胸痛" :checkrowdata="mrdata" /></el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="主诉与病史" name="medicalHistory">
        <medicalHistory v-if="activeName == 'medicalHistory'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="GRACE" name="checkUp"><checkUp v-if="activeName == 'checkUp'" :checkrowdata="mrdata" /></el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="辅助检查" name="accessoryExamination">
        <accessoryExamination v-if="activeName == 'accessoryExamination'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="血液检查" name="bloodExamination">
        <bloodExamination v-if="activeName == 'bloodExamination'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="诊断评估" name="diagnosticEstimate">
        <diagnostic-estimate v-if="activeName == 'diagnosticEstimate'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="处理措施" name="treatmentMeasures">
        <treatmentMeasures v-if="activeName == 'treatmentMeasures'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="治疗" name="treatment">
        <treatment v-if="activeName == 'treatment'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="其他处置" name="otherDisposal">
        <otherDisposal v-if="activeName == 'otherDisposal'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="知情同意" name="informedConsentList">
        <informedConsentList v-if="activeName == 'informedConsentList'" :checkrowdata="mrdata" />
      </el-tab-pane>
      <el-tab-pane v-if="consultation == false" label="患者转归" name="outcome">
        <outcome v-if="activeName == 'outcome'" :checkrowdata="mrdata" />
      </el-tab-pane>

      <!-- 新版页面,仅在会诊中使用 -->
      <el-tab-pane v-if="consultation == true" label="基本信息" name="basicInfo"><basicInfo v-if="activeName == 'basicInfo'" :checkrowdata="mrdata" /></el-tab-pane>
      <el-tab-pane label="上报表单（v2.1）" name="reportForm21"><reportForm21 v-if="activeName == 'reportForm21'" :checkrowdata="mrdata" /></el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import process from '@/views/green-channel/process.vue'
import info from '@/views/green-channel/info.vue'
import remoteConsultation from '@/views/green-channel/remoteConsultation.vue'
import vitalSign from '@/views/green-channel/vitalSign.vue'
import medicalHistory from '@/views/green-channel/medicalHistory.vue'
import checkUp from '@/views/green-channel/checkUp.vue'
import accessoryExamination from '@/views/green-channel/accessoryExamination.vue'
import bloodExamination from '@/views/green-channel/bloodExamination.vue'
import treatment from '@/views/green-channel/treatment.vue'
import reportForm21 from '@/views/green-channel/reportForm21.vue'
import basicInfo from '@/views/green-channel/basicInfo.vue'
import otherDisposal from '@/views/green-channel/otherDisposal.vue'
import informedConsentList from '@/views/green-channel/informedConsentList.vue'
import diagnosticEstimate from '@/views/green-channel/diagnosticEstimate.vue'
import outcome from '@/views/green-channel/outcome.vue'
import treatmentMeasures from '@/views/green-channel/treatmentMeasures.vue'
import { getPatientInfo } from '@/api/green-channel/tab-request'

export default {
  // 由主页面(父组件) 接收来的, 选择项的数据
  components: {
    process,
    info,
    remoteConsultation,
    vitalSign,
    medicalHistory,
    checkUp,
    accessoryExamination,
    bloodExamination,
    reportForm21,
    basicInfo,
    treatment,
    otherDisposal,
    informedConsentList,
    diagnosticEstimate,
    outcome,
    treatmentMeasures
  },
  props: ['mrdata'],
  data() {
    return {
      activeName: 'process',
      persondata: {},
      insname: '',
      consultation: false // 是否由会诊tab页进入
    }
  },
  computed: {},
  updated() {},
  created() {
    console.log('接受要传的值', this.mrdata)
    this.insname = this.$store.getters.hospitalName
    console.log(this.$store.getters, 'getters')
    console.log('是否由会诊tab页进入', this.mrdata.isConsultation) // true或false
    if (this.mrdata.isConsultation) {
      this.consultation = this.mrdata.isConsultation
      this.activeName = 'basicInfo'
    }
    if (this.mrdata.state === 'creating') {
      this.activeName = 'info'
    }
    if (this.mrdata.abNormal) {
      this.activeName = 'reportForm21'
    }
    console.log('进入患者详情页面-----')
    getPatientInfo(this.mrdata.patientId).then(res => {
      if (res) {
        this.persondata = res
      }
    })
  },
  mounted() {
    if (!!this.$store.getters.consultationsId && this.$store.getters.dataBus.dispatchId) {
      // cid有值 && dastabus有值
      // this.checkData = this.$store.getters.dataBus // checkData赋值
      this.consultation = true
      this.activeName = 'basicInfo'
      console.log(this.mrdata, 'mrdata')
    }
  },
  methods: {
    handleClick(e, a) {
      // console.log(e, a)
      // console.log(this.activeName.toString())
      // console.log(this.activeName === 'reportForm21')
    },
    routerBack() {
      console.log('点击后退-------')
      // this.$router.push('/green-channel/patients-list')
      this.$emit('medicalRecordsToFather') // 提醒父组件切换页面,达成返回效果
      // this.$emit('homePageToFather', data.dispatchId, data.patientId)
      // console.log(this.$router)
      // this.$router.back()
      // this.$router.go(-1) // 后退
      // debugger
      // this.$router.push('/green-channel/medicalRecords')
      // 接受子组件传来的dispatchId,patientId
      // console.log('传来的数据', dispatchId, patientId)
    }
  }
}
</script>

<style scoped>
.topLine {
  background-color: rgb(255, 255, 255);
  color: rgb(57, 68, 85);
  overflow: hidden;
  z-index: 9999;
  padding: 10px 20px;
  text-align: center;
  border-bottom: 10px solid rgb(242, 242, 242);
}

.blueDot {
  width: 15px;
  height: 15px;
  line-height: 30px;
  background-color: rgb(67, 128, 234);
  border-radius: 50%;
  float: left;
  margin-top: 15px;
}
</style>
